package vista;

import controlador.ControladorListadoIngrediente;

import java.awt.event.ActionListener;
import java.util.Vector;
import javax.swing.table.DefaultTableModel;

import modelo.Ingrediente;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VentanaListadoIngredientes extends javax.swing.JFrame {
    private ControladorListadoIngrediente control;
    private DefaultTableModel modeloTabla;
    private Vector<String> fila;

  
    public VentanaListadoIngredientes() {
        initComponents();
        modeloTabla= new DefaultTableModel();
        tblListado.setModel(modeloTabla);

        fila= new Vector<String>();

        fila.add("Ingrediente");
        fila.add("Cantidad Disponible en Almacen");
        modeloTabla.setColumnIdentifiers(fila);
        
        control = new  ControladorListadoIngrediente(this);
        addAction();
    }

    public void addListener(ActionListener escuchador){
        btnSalir.addActionListener(escuchador);
        btnConsultar.addActionListener(escuchador);
    }

    public void addAction(){
            btnConsultar.setActionCommand("Consultar");
            btnSalir.setActionCommand("Salir");
    }

    public void agregar(Ingrediente m){
        fila= new Vector<String>();
        fila.add(m.getDescripcion());
        fila.add(""+m.getStock());

                modeloTabla.addRow(fila);
            
        }

    public DefaultTableModel getModeloTabla() {
        return modeloTabla;
    }

   @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane2 = new javax.swing.JScrollPane();
        tblListado = new javax.swing.JTable();
        btnSalir = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        btnConsultar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(null);

        tblListado.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(tblListado);

        getContentPane().add(jScrollPane2);
        jScrollPane2.setBounds(16, 28, 452, 394);
        jScrollPane2.setBackground(new java.awt.Color(255,255,255));

        btnSalir.setFont(new java.awt.Font("Ubuntu",1,15)); // NOI18N
        btnSalir.setText("Salir");
        getContentPane().add(btnSalir);
        btnSalir.setBounds(259, 434, 120, 30);
        btnSalir.setSize(100, 23);

        jLabel4.setFont(new java.awt.Font("Ubuntu",1,15));
        jLabel4.setText("Stock de Ingredientes");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(145, 4, 212, 22);

        btnConsultar.setFont(new java.awt.Font("Ubuntu",1,15)); // NOI18N
        btnConsultar.setText("Consultar");
        getContentPane().add(btnConsultar);
        btnConsultar.setBounds(102, 434, 120, 30);
        btnConsultar.setSize(100, 23);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        this.setBounds(0, 0, 491, 497);
        this.setTitle("Listado de Ingredientes");
        getContentPane().setBackground(new java.awt.Color(255,255,255));
    }// </editor-fold>//GEN-END:initComponents

    
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VentanaListadoIngredientes().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnConsultar;
    private javax.swing.JButton btnSalir;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable tblListado;
    // End of variables declaration//GEN-END:variables

}
